<%--
Created by IntelliJ IDEA.
User: wang
Date: 2021/3/16/016
Time: 18:36
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/common/headerAndLeft.jsp" %>
<div class="right">
    <div class="location">
        <strong>你现在所在的位置是:</strong>
        <span>供应商管理页面</span>
    </div>
    <div class="search">
        <form action="${ctx}/provider/providerList" method="post" name="searchForm" id="searchForm">
            <span>供应商名称：</span>
            <input type="text" name="proName" value="${param.proName}" placeholder="请输入供应商的名称"/>
            <input type="hidden" name="pageIndex" value="1"/>
            <input type="hidden" name="pageSize" value="6"/>
            <input type="button" value="查询" id="btn1"/>
            <c:if test="${user.userRole!=3}">
                <a href="javaScript:void(0)" class="addProvider">添加供应商</a>
            </c:if>
        </form>

    </div>
    <!--供应商操作表格-->
    <table class="providerTable" cellpadding="0" cellspacing="0">
        <tr class="firstTr">
            <th width="10%">供应商编码</th>
            <th width="20%">供应商名称</th>
            <th width="10%">联系人</th>
            <th width="10%">联系电话</th>
            <th width="10%">传真</th>
            <th width="10%">创建时间</th>
            <th width="30%">操作</th>
        </tr>
        <c:if test="${empty pageInfo.lists}">
            <tr>
                <td colspan="5" style="font-size: 16px">查询不到相关信息，请检查检索条件重新检索！</td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </c:if>
        <c:forEach items="${pageInfo.lists}" var="provider1" varStatus="counts">
            <tr <c:if test="${counts.count%2 eq 0}"> class="admin-list-td-h2" </c:if>>
                <td>${provider1.proCode}</td>
                <td>${provider1.proName}</td>
                <td>${provider1.proContact}</td>
                <td>${provider1.proPhone}</td>
                <td>
                    <c:if test="${provider1.proFax==null}">暂无</c:if>
                        ${provider1.proFax}
                </td>
                <td>
                    <fmt:formatDate value="${provider1.creationDate}" pattern="yyyy-MM-dd"/>
                </td>
                <td>
                    <c:choose>
                        <c:when test="${user.userRole==1}">
                            <a href="${ctx}/provider/view?id=${provider1.id}"><img src="${ctx}/statics/images/read.png"
                                                                                   alt="查看" title="查看"/></a>
                            <a href="javaScript:void(0)" id="${provider1.id}" class="providerUpdate"><img
                                    src="${ctx}/statics/images/xiugai.png" alt="修改" title="修改"/></a>
                            <a href="javaScript:void(0)" class="removeProvider" id="${provider1.id}"><img
                                    src="${ctx}/statics/images/schu.png" alt="删除" title="删除"/></a>
                        </c:when>
                        <c:when test="${user.userRole==2}">
                            <a href="${ctx}/provider/view?id=${provider1.id}"><img src="${ctx}/statics/images/read.png"
                                                                                   alt="查看" title="查看"/></a>
                            <a href="javaScript:void(0)" id="${provider1.id}" class="providerUpdate"><img
                                    src="${ctx}/statics/images/xiugai.png" alt="修改" title="修改"/></a>
                        </c:when>
                        <c:when test="${user.userRole==3}">
                            没有权限操作
                        </c:when>
                    </c:choose>

                </td>
            </tr>
        </c:forEach>
    </table>

    <%--分页条--%>
    <div class="pageNav" style="margin-top: 50px">
        <c:import url="/common/pageNavPageHelper.jsp">
            <c:param name="pageNum" value="${pageInfo.pageNum}"></c:param>
            <c:param name="pageSize" value="${pageInfo.pageSize}"></c:param>
            <c:param name="total" value="${pageInfo.total}"></c:param>
            <c:param name="pages" value="${pageInfo.pages}"></c:param>
        </c:import>
    </div>

    <div class="providerUpdateView"></div>
    <div class="providerAddView"></div>

    <div class="addView"></div>


</div>
</section>

<%--providerAdd--%>
<script type="text/javascript">
    $(function () {
        $(".addProvider").click(function () {
            $(".addVIew").load(
                "${ctx}/provider/toProviderAdd"
            );
        });
    });
</script>

<%--providerUpdate--%>
<script type="text/javascript">
    $(function () {
        $(".providerUpdate").click(function () {
            $(".addVIew").load(
                "${ctx}/provider/toProviderUpdate",
                {"id": $(this).attr("id")}
            );
        });
    });
</script>

<%--条件分页查询按钮提交--%>
<script type="text/javascript">
    $(function () {
        $("#btn1").click(function () {
            $("#searchForm").submit();
        });
    });
</script>

<!--点击删除按钮后弹出的页面-->
<div class="zhezhao"></div>
<div class="remove" id="removeProv">
    <div class="removerChid">
        <h2>提示</h2>
        <div class="removeMain">
            <p>你确定要删除该供应商吗？</p>
            <a href="#" id="yesProvider">确定</a>
            <a href="#" id="no">取消</a>
        </div>
    </div>
</div>


<footer class="footer">
    版权归北大青鸟
</footer>


</body>
</html>